package sudroid.json;

import java.io.IOException;
import java.io.Writer;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.util.Collection;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
import java.util.TreeSet;

public class JSONObject
{
  public static final Object NULL = new Null();
  private Map map;

  public JSONObject()
  {
    HashMap localHashMap = new HashMap();
    this.map = localHashMap;
  }

  public JSONObject(Object paramObject)
  {
    this();
    populateInternalMap(paramObject, 0);
  }

  public JSONObject(Object paramObject, boolean paramBoolean)
  {
    this();
    populateInternalMap(paramObject, paramBoolean);
  }

  public JSONObject(Object paramObject, String[] paramArrayOfString)
  {
    this();
    Class localClass = paramObject.getClass();
    int i = 0;
    while (true)
    {
      int j = paramArrayOfString.length;
      if (i >= j)
        return;
      String str = paramArrayOfString[i];
      try
      {
        Object localObject = localClass.getField(str).get(paramObject);
        JSONObject localJSONObject = putOpt(str, localObject);
        label52: i += 1;
      }
      catch (Exception localException)
      {
        break label52;
      }
    }
  }

  public JSONObject(String paramString)
    throws JSONException
  {
    this(localJSONTokener);
  }

  public JSONObject(Map paramMap)
  {
    if (paramMap == null);
    for (Object localObject = new HashMap(); ; localObject = paramMap)
    {
      this.map = ((Map)localObject);
      return;
    }
  }

  public JSONObject(Map paramMap, boolean paramBoolean)
  {
    HashMap localHashMap = new HashMap();
    this.map = localHashMap;
    Iterator localIterator;
    if (paramMap != null)
      localIterator = paramMap.entrySet().iterator();
    while (true)
    {
      if (!localIterator.hasNext())
        return;
      Map.Entry localEntry = (Map.Entry)localIterator.next();
      Map localMap = this.map;
      Object localObject1 = localEntry.getKey();
      Object localObject2 = localEntry.getValue();
      JSONObject localJSONObject = new JSONObject(localObject2, paramBoolean);
      Object localObject3 = localMap.put(localObject1, localJSONObject);
    }
  }

  public JSONObject(JSONObject paramJSONObject, String[] paramArrayOfString)
    throws JSONException
  {
    this();
    int i = 0;
    while (true)
    {
      int j = paramArrayOfString.length;
      if (i >= j)
        return;
      String str1 = paramArrayOfString[i];
      String str2 = paramArrayOfString[i];
      Object localObject = paramJSONObject.opt(str2);
      JSONObject localJSONObject = putOnce(str1, localObject);
      i += 1;
    }
  }

  public JSONObject(JSONTokener paramJSONTokener)
    throws JSONException
  {
    this();
    if (paramJSONTokener.nextClean() != 123)
      throw paramJSONTokener.syntaxError("A JSONObject text must begin with '{'");
    do
    {
      paramJSONTokener.back();
      String str;
      int i;
      switch (paramJSONTokener.nextClean())
      {
      default:
        paramJSONTokener.back();
        str = paramJSONTokener.nextValue().toString();
        i = paramJSONTokener.nextClean();
        if (i == 61)
        {
          if (paramJSONTokener.next() == 62)
            break;
          paramJSONTokener.back();
        }
      case '\000':
        do
        {
          Object localObject = paramJSONTokener.nextValue();
          JSONObject localJSONObject = putOnce(str, localObject);
          switch (paramJSONTokener.nextClean())
          {
          default:
            throw paramJSONTokener.syntaxError("Expected a ',' or '}'");
            throw paramJSONTokener.syntaxError("A JSONObject text must end with '}'");
          case ',':
          case ';':
          case '}':
          }
        }
        while (i == 58);
        throw paramJSONTokener.syntaxError("Expected a ':' after a key");
      case '}':
      }
    }
    while (paramJSONTokener.nextClean() != 125);
  }

  public static String doubleToString(double paramDouble)
  {
    Object localObject;
    if ((Double.isInfinite(paramDouble)) || (Double.isNaN(paramDouble)))
    {
      localObject = "null";
      return localObject;
    }
    String str = Double.toString(paramDouble);
    if ((str.indexOf('.') > 0) && (str.indexOf('e') < 0) && (str.indexOf('E') < 0));
    while (true)
    {
      if (!str.endsWith("0"))
      {
        if (str.endsWith("."))
        {
          int i = str.length() - 1;
          str = str.substring(0, i);
        }
        localObject = str;
        break;
      }
      int j = str.length() - 1;
      str = str.substring(0, j);
    }
  }

  public static String[] getNames(Object paramObject)
  {
    Object localObject = null;
    if (paramObject == null);
    Field[] arrayOfField;
    int i;
    do
    {
      return localObject;
      arrayOfField = paramObject.getClass().getFields();
      i = arrayOfField.length;
    }
    while (i == 0);
    String[] arrayOfString = new String[i];
    int j = 0;
    while (true)
    {
      if (j >= i)
      {
        localObject = arrayOfString;
        break;
      }
      String str = arrayOfField[j].getName();
      arrayOfString[j] = str;
      j += 1;
    }
  }

  public static String[] getNames(JSONObject paramJSONObject)
  {
    int i = paramJSONObject.length();
    Object localObject;
    if (i == 0)
    {
      localObject = null;
      return localObject;
    }
    Iterator localIterator = paramJSONObject.keys();
    String[] arrayOfString = new String[i];
    int j = 0;
    while (true)
    {
      if (!localIterator.hasNext())
      {
        localObject = arrayOfString;
        break;
      }
      String str = (String)localIterator.next();
      arrayOfString[j] = str;
      j += 1;
    }
  }

  private boolean isStandardProperty(Class paramClass)
  {
    if ((!paramClass.isPrimitive()) && (!paramClass.isAssignableFrom(Byte.class)) && (!paramClass.isAssignableFrom(Short.class)) && (!paramClass.isAssignableFrom(Integer.class)) && (!paramClass.isAssignableFrom(Long.class)) && (!paramClass.isAssignableFrom(Float.class)) && (!paramClass.isAssignableFrom(Double.class)) && (!paramClass.isAssignableFrom(Character.class)) && (!paramClass.isAssignableFrom(String.class)) && (!paramClass.isAssignableFrom(Boolean.class)));
    for (int i = 0; ; i = 1)
      return i;
  }

  public static String numberToString(Number paramNumber)
    throws JSONException
  {
    if (paramNumber == null)
      throw new JSONException("Null pointer");
    testValidity(paramNumber);
    String str = paramNumber.toString();
    if ((str.indexOf('.') > 0) && (str.indexOf('e') < 0) && (str.indexOf('E') < 0));
    while (true)
    {
      if (!str.endsWith("0"))
      {
        if (str.endsWith("."))
        {
          int i = str.length() - 1;
          str = str.substring(0, i);
        }
        return str;
      }
      int j = str.length() - 1;
      str = str.substring(0, j);
    }
  }

  private void populateInternalMap(Object paramObject, boolean paramBoolean)
  {
    Class localClass1 = paramObject.getClass();
    if (localClass1.getClassLoader() == null)
      paramBoolean = false;
    if (paramBoolean);
    int i;
    for (Method[] arrayOfMethod = localClass1.getMethods(); ; arrayOfMethod = localClass1.getDeclaredMethods())
    {
      i = 0;
      int j = arrayOfMethod.length;
      if (i < j)
        break;
      return;
    }
    while (true)
    {
      String str2;
      Object localObject1;
      try
      {
        Method localMethod = arrayOfMethod[i];
        String str1 = localMethod.getName();
        str2 = "";
        if (!str1.startsWith("get"))
          continue;
        str2 = str1.substring(3);
        if ((str2.length() <= 0) || (!Character.isUpperCase(str2.charAt(0))) || (localMethod.getParameterTypes().length != 0))
          continue;
        if (str2.length() != 1)
          continue;
        str2 = str2.toLowerCase();
        localObject1 = localMethod.invoke(paramObject, null);
        if (localObject1 != null)
          continue;
        Map localMap1 = this.map;
        Object localObject2 = NULL;
        Object localObject3 = localMap1.put(str2, localObject2);
        i += 1;
        break;
        if (!str1.startsWith("is"))
          continue;
        str2 = str1.substring(2);
        continue;
        if (Character.isUpperCase(str2.charAt(1)))
          continue;
        String str3 = String.valueOf(str2.substring(0, 1).toLowerCase());
        StringBuilder localStringBuilder = new StringBuilder(str3);
        String str4 = str2.substring(1);
        str2 = str4;
        continue;
        if (localObject1.getClass().isArray())
        {
          Map localMap2 = this.map;
          JSONArray localJSONArray1 = new JSONArray(localObject1, paramBoolean);
          Object localObject4 = localMap2.put(str2, localJSONArray1);
          continue;
        }
      }
      catch (Exception localException)
      {
        throw new RuntimeException(localException);
      }
      if ((localObject1 instanceof Collection))
      {
        Map localMap3 = this.map;
        Collection localCollection = (Collection)localObject1;
        JSONArray localJSONArray2 = new JSONArray(localCollection, paramBoolean);
        Object localObject5 = localMap3.put(str2, localJSONArray2);
        continue;
      }
      if ((localObject1 instanceof Map))
      {
        Map localMap4 = this.map;
        Map localMap5 = (Map)localObject1;
        JSONObject localJSONObject1 = new JSONObject(localMap5, paramBoolean);
        Object localObject6 = localMap4.put(str2, localJSONObject1);
        continue;
      }
      Class localClass2 = localObject1.getClass();
      if (isStandardProperty(localClass2))
      {
        Object localObject7 = this.map.put(str2, localObject1);
        continue;
      }
      if ((localObject1.getClass().getPackage().getName().startsWith("java")) || (localObject1.getClass().getClassLoader() == null))
      {
        Map localMap6 = this.map;
        String str5 = localObject1.toString();
        Object localObject8 = localMap6.put(str2, str5);
        continue;
      }
      Map localMap7 = this.map;
      JSONObject localJSONObject2 = new JSONObject(localObject1, paramBoolean);
      Object localObject9 = localMap7.put(str2, localJSONObject2);
    }
  }

  public static String quote(String paramString)
  {
    if ((paramString == null) || (paramString.length() == 0));
    StringBuffer localStringBuffer1;
    int m;
    for (String str1 = "\"\""; ; str1 = localStringBuffer1.toString())
    {
      return str1;
      i = 0;
      int j = paramString.length();
      int k = j + 4;
      localStringBuffer1 = new StringBuffer(k);
      StringBuffer localStringBuffer2 = localStringBuffer1.append(34);
      m = 0;
      if (m < j)
        break;
      StringBuffer localStringBuffer3 = localStringBuffer1.append(34);
    }
    int n = i;
    int i = paramString.charAt(m);
    switch (i)
    {
    default:
      if ((i >= 32) && ((i < 128) || (i >= 160)) && ((i < 8192) || (i >= 8448)))
        break;
      StringBuilder localStringBuilder1 = new StringBuilder("000");
      String str2 = Integer.toHexString(i);
      String str3 = str2;
      StringBuilder localStringBuilder2 = new StringBuilder("\\u");
      int i1 = str3.length() - 4;
      String str4 = str3.substring(i1);
      String str5 = str4;
      StringBuffer localStringBuffer4 = localStringBuffer1.append(str5);
    case 34:
    case 92:
    case 47:
    case 8:
    case 9:
    case 10:
    case 12:
    case 13:
    }
    while (true)
    {
      m += 1;
      break;
      StringBuffer localStringBuffer5 = localStringBuffer1.append(92);
      StringBuffer localStringBuffer6 = localStringBuffer1.append(i);
      continue;
      if (n == 60)
        StringBuffer localStringBuffer7 = localStringBuffer1.append(92);
      StringBuffer localStringBuffer8 = localStringBuffer1.append(i);
      continue;
      StringBuffer localStringBuffer9 = localStringBuffer1.append("\\b");
      continue;
      StringBuffer localStringBuffer10 = localStringBuffer1.append("\\t");
      continue;
      StringBuffer localStringBuffer11 = localStringBuffer1.append("\\n");
      continue;
      StringBuffer localStringBuffer12 = localStringBuffer1.append("\\f");
      continue;
      StringBuffer localStringBuffer13 = localStringBuffer1.append("\\r");
      continue;
      StringBuffer localStringBuffer14 = localStringBuffer1.append(i);
    }
  }

  public static Object stringToValue(String paramString)
  {
    Object localObject;
    if (paramString.equals(""))
      localObject = paramString;
    while (true)
    {
      return localObject;
      if (paramString.equalsIgnoreCase("true"))
      {
        localObject = Boolean.TRUE;
        continue;
      }
      if (paramString.equalsIgnoreCase("false"))
      {
        localObject = Boolean.FALSE;
        continue;
      }
      if (paramString.equalsIgnoreCase("null"))
      {
        localObject = NULL;
        continue;
      }
      int i = paramString.charAt(0);
      if (((i >= 48) && (i <= 57)) || (i == 46) || (i == 45) || (i == 43))
        if (i == 48)
        {
          if ((paramString.length() <= 2) || ((paramString.charAt(1) != 120) && (paramString.charAt(1) != 88)))
            break label213;
          try
          {
            int j = Integer.parseInt(paramString.substring(2), 16);
            localObject = new Integer(j);
          }
          catch (Exception localException1)
          {
          }
        }
    }
    while (true)
      while (true)
      {
        try
        {
          localObject = new Integer(paramString);
        }
        catch (Exception localException2)
        {
          try
          {
            localObject = new Long(paramString);
          }
          catch (Exception localException3)
          {
            try
            {
              localObject = new Double(paramString);
            }
            catch (Exception localException4)
            {
            }
          }
        }
        localObject = paramString;
        break;
        try
        {
          label213: int k = Integer.parseInt(paramString, 8);
          localObject = new Integer(k);
        }
        catch (Exception localException5)
        {
        }
      }
  }

  static void testValidity(Object paramObject)
    throws JSONException
  {
    if (paramObject != null)
      if ((paramObject instanceof Double))
      {
        if ((((Double)paramObject).isInfinite()) || (((Double)paramObject).isNaN()))
          throw new JSONException("JSON does not allow non-finite numbers.");
      }
      else if (((paramObject instanceof Float)) && ((((Float)paramObject).isInfinite()) || (((Float)paramObject).isNaN())))
        throw new JSONException("JSON does not allow non-finite numbers.");
  }

  static String valueToString(Object paramObject)
    throws JSONException
  {
    String str1;
    if ((paramObject == null) || (paramObject.equals("null")))
      str1 = "null";
    while (true)
    {
      return str1;
      if ((paramObject instanceof JSONString))
      {
        String str3;
        try
        {
          String str2 = ((JSONString)paramObject).toJSONString();
          str3 = str2;
          if ((str3 instanceof String))
            str1 = (String)str3;
        }
        catch (Exception localException)
        {
          throw new JSONException(localException);
        }
        String str4 = "Bad value from toJSONString: " + str3;
        throw new JSONException(str4);
      }
      if ((paramObject instanceof Number))
      {
        str1 = numberToString((Number)paramObject);
        continue;
      }
      if (((paramObject instanceof Boolean)) || ((paramObject instanceof JSONObject)) || ((paramObject instanceof JSONArray)))
      {
        str1 = paramObject.toString();
        continue;
      }
      if ((paramObject instanceof Map))
      {
        Map localMap = (Map)paramObject;
        str1 = new JSONObject(localMap).toString();
        continue;
      }
      if ((paramObject instanceof Collection))
      {
        Collection localCollection = (Collection)paramObject;
        str1 = new JSONArray(localCollection).toString();
        continue;
      }
      if (paramObject.getClass().isArray())
      {
        str1 = new JSONArray(paramObject).toString();
        continue;
      }
      str1 = quote(paramObject.toString());
    }
  }

  static String valueToString(Object paramObject, int paramInt1, int paramInt2)
    throws JSONException
  {
    Object localObject;
    if ((paramObject == null) || (paramObject.equals("null")))
      localObject = "null";
    while (true)
    {
      return localObject;
      try
      {
        if ((paramObject instanceof JSONString))
        {
          String str = ((JSONString)paramObject).toJSONString();
          if ((str instanceof String))
          {
            str = (String)str;
            localObject = str;
          }
        }
      }
      catch (Exception localException)
      {
        if ((paramObject instanceof Number))
        {
          localObject = numberToString((Number)paramObject);
          continue;
        }
        if ((paramObject instanceof Boolean))
        {
          localObject = paramObject.toString();
          continue;
        }
        if ((paramObject instanceof JSONObject))
        {
          localObject = ((JSONObject)paramObject).toString(paramInt1, paramInt2);
          continue;
        }
        if ((paramObject instanceof JSONArray))
        {
          localObject = ((JSONArray)paramObject).toString(paramInt1, paramInt2);
          continue;
        }
        if ((paramObject instanceof Map))
        {
          Map localMap = (Map)paramObject;
          localObject = new JSONObject(localMap).toString(paramInt1, paramInt2);
          continue;
        }
        if ((paramObject instanceof Collection))
        {
          Collection localCollection = (Collection)paramObject;
          localObject = new JSONArray(localCollection).toString(paramInt1, paramInt2);
          continue;
        }
        if (paramObject.getClass().isArray())
        {
          localObject = new JSONArray(paramObject).toString(paramInt1, paramInt2);
          continue;
        }
        localObject = quote(paramObject.toString());
      }
    }
  }

  public JSONObject accumulate(String paramString, Object paramObject)
    throws JSONException
  {
    testValidity(paramObject);
    Object localObject1 = opt(paramString);
    Object localObject2;
    if (localObject1 == null)
      if ((paramObject instanceof JSONArray))
      {
        localObject2 = new JSONArray().put(paramObject);
        JSONObject localJSONObject1 = put(paramString, localObject2);
      }
    while (true)
    {
      return this;
      localObject2 = paramObject;
      break;
      if ((localObject1 instanceof JSONArray))
      {
        JSONArray localJSONArray1 = ((JSONArray)localObject1).put(paramObject);
        continue;
      }
      JSONArray localJSONArray2 = new JSONArray().put(localObject1).put(paramObject);
      JSONObject localJSONObject2 = put(paramString, localJSONArray2);
    }
  }

  public JSONObject append(String paramString, Object paramObject)
    throws JSONException
  {
    testValidity(paramObject);
    Object localObject = opt(paramString);
    if (localObject == null)
    {
      JSONArray localJSONArray1 = new JSONArray().put(paramObject);
      JSONObject localJSONObject1 = put(paramString, localJSONArray1);
    }
    while (true)
    {
      return this;
      if (!(localObject instanceof JSONArray))
        break;
      JSONArray localJSONArray2 = ((JSONArray)localObject).put(paramObject);
      JSONObject localJSONObject2 = put(paramString, localJSONArray2);
    }
    String str = "JSONObject[" + paramString + "] is not a JSONArray.";
    throw new JSONException(str);
  }

  public Object get(String paramString)
    throws JSONException
  {
    return opt(paramString);
  }

  public boolean getBoolean(String paramString)
    throws JSONException
  {
    Object localObject = get(paramString);
    int i;
    if (localObject == null)
      i = 0;
    while (true)
    {
      return i;
      Boolean localBoolean1 = Boolean.FALSE;
      if ((localObject.equals(localBoolean1)) || (((localObject instanceof String)) && (((String)localObject).equalsIgnoreCase("false"))))
      {
        i = 0;
        continue;
      }
      Boolean localBoolean2 = Boolean.TRUE;
      if ((!localObject.equals(localBoolean2)) && ((!(localObject instanceof String)) || (!((String)localObject).equalsIgnoreCase("true"))))
        break;
      i = 1;
    }
    StringBuilder localStringBuilder = new StringBuilder("JSONObject[");
    String str1 = quote(paramString);
    String str2 = str1 + "] is not a Boolean.";
    throw new JSONException(str2);
  }

  public double getDouble(String paramString)
    throws JSONException
  {
    Object localObject = get(paramString);
    long l1;
    if (localObject == null)
      l1 = 0L;
    String str2;
    while (true)
    {
      return l1;
      try
      {
        double d1;
        if ((localObject instanceof Number))
        {
          d1 = ((Number)localObject).doubleValue();
          continue;
        }
        if (localObject.toString().length() > 0)
        {
          double d2 = Double.valueOf(localObject.toString()).doubleValue();
          d1 = d2;
          continue;
        }
        long l2 = 0L;
      }
      catch (Exception localException)
      {
        StringBuilder localStringBuilder = new StringBuilder("JSONObject[");
        String str1 = quote(paramString);
        str2 = str1 + "] is not a number.";
      }
    }
    throw new JSONException(str2);
  }

  public int getInt(String paramString)
    throws JSONException
  {
    Object localObject = get(paramString);
    int i;
    if (localObject == null)
      i = 0;
    while (true)
    {
      return i;
      if ((localObject instanceof Number))
      {
        i = ((Number)localObject).intValue();
        continue;
      }
      i = (int)getDouble(paramString);
    }
  }

  public JSONArray getJSONArray(String paramString)
    throws JSONException
  {
    Object localObject = get(paramString);
    if (localObject == null);
    for (JSONArray localJSONArray = null; ; localJSONArray = (JSONArray)localObject)
    {
      return localJSONArray;
      if (!(localObject instanceof JSONArray))
        break;
    }
    StringBuilder localStringBuilder = new StringBuilder("JSONObject[");
    String str1 = quote(paramString);
    String str2 = str1 + "] is not a JSONArray.";
    throw new JSONException(str2);
  }

  public JSONObject getJSONObject(String paramString)
    throws JSONException
  {
    Object localObject = get(paramString);
    if (localObject == null);
    for (JSONObject localJSONObject = null; ; localJSONObject = (JSONObject)localObject)
    {
      return localJSONObject;
      if (!(localObject instanceof JSONObject))
        break;
    }
    StringBuilder localStringBuilder = new StringBuilder("JSONObject[");
    String str1 = quote(paramString);
    String str2 = str1 + "] is not a JSONObject.";
    throw new JSONException(str2);
  }

  public long getLong(String paramString)
    throws JSONException
  {
    Object localObject = get(paramString);
    long l;
    if (localObject == null)
      l = 0L;
    while (true)
    {
      return l;
      if ((localObject instanceof String))
      {
        if (localObject.toString().length() > 0)
        {
          l = Long.valueOf(localObject.toString()).longValue();
          continue;
        }
        l = 0L;
        continue;
      }
      if ((localObject instanceof Number))
      {
        l = ((Number)localObject).longValue();
        continue;
      }
      l = ()getDouble(paramString);
    }
  }

  public String getString(String paramString)
    throws JSONException
  {
    Object localObject = get(paramString);
    if (localObject == null);
    for (String str = ""; ; str = localObject.toString())
      return str;
  }

  public boolean has(String paramString)
  {
    return this.map.containsKey(paramString);
  }

  public boolean isNull(String paramString)
  {
    Object localObject1 = NULL;
    Object localObject2 = opt(paramString);
    return localObject1.equals(localObject2);
  }

  public Iterator keys()
  {
    return this.map.keySet().iterator();
  }

  public int length()
  {
    return this.map.size();
  }

  public JSONArray names()
  {
    JSONArray localJSONArray1 = new JSONArray();
    Iterator localIterator = keys();
    if (!localIterator.hasNext())
      if (localJSONArray1.length() != 0)
        break label52;
    label52: for (JSONArray localJSONArray2 = null; ; localJSONArray2 = localJSONArray1)
    {
      return localJSONArray2;
      Object localObject = localIterator.next();
      JSONArray localJSONArray3 = localJSONArray1.put(localObject);
      break;
    }
  }

  public Object opt(String paramString)
  {
    if (paramString == null);
    for (Object localObject = null; ; localObject = this.map.get(paramString))
      return localObject;
  }

  public boolean optBoolean(String paramString)
  {
    return optBoolean(paramString, 0);
  }

  public boolean optBoolean(String paramString, boolean paramBoolean)
  {
    try
    {
      boolean bool1 = getBoolean(paramString);
      bool2 = bool1;
      return bool2;
    }
    catch (Exception localException)
    {
      while (true)
        boolean bool2 = paramBoolean;
    }
  }

  public double optDouble(String paramString)
  {
    return optDouble(paramString, (0.0D / 0.0D));
  }

  public double optDouble(String paramString, double paramDouble)
  {
    try
    {
      Object localObject = opt(paramString);
      if ((localObject instanceof Number))
        d1 = ((Number)localObject).doubleValue();
      while (true)
      {
        return d1;
        String str = (String)localObject;
        double d2 = new Double(str).doubleValue();
        d1 = d2;
      }
    }
    catch (Exception localException)
    {
      while (true)
        double d1 = paramDouble;
    }
  }

  public int optInt(String paramString)
  {
    return optInt(paramString, 0);
  }

  public int optInt(String paramString, int paramInt)
  {
    try
    {
      int i = getInt(paramString);
      j = i;
      return j;
    }
    catch (Exception localException)
    {
      while (true)
        int j = paramInt;
    }
  }

  public JSONArray optJSONArray(String paramString)
  {
    Object localObject = opt(paramString);
    if ((localObject instanceof JSONArray));
    for (JSONArray localJSONArray = (JSONArray)localObject; ; localJSONArray = null)
      return localJSONArray;
  }

  public JSONObject optJSONObject(String paramString)
  {
    Object localObject = opt(paramString);
    if ((localObject instanceof JSONObject));
    for (JSONObject localJSONObject = (JSONObject)localObject; ; localJSONObject = null)
      return localJSONObject;
  }

  public long optLong(String paramString)
  {
    return optLong(paramString, 0L);
  }

  public long optLong(String paramString, long paramLong)
  {
    try
    {
      long l1 = getLong(paramString);
      l2 = l1;
      return l2;
    }
    catch (Exception localException)
    {
      while (true)
        long l2 = paramLong;
    }
  }

  public String optString(String paramString)
  {
    return optString(paramString, "");
  }

  public String optString(String paramString1, String paramString2)
  {
    Object localObject = opt(paramString1);
    if (localObject != null);
    for (String str = localObject.toString(); ; str = paramString2)
      return str;
  }

  public JSONObject put(String paramString, double paramDouble)
    throws JSONException
  {
    Double localDouble = new Double(paramDouble);
    JSONObject localJSONObject = put(paramString, localDouble);
    return this;
  }

  public JSONObject put(String paramString, int paramInt)
    throws JSONException
  {
    Integer localInteger = new Integer(paramInt);
    JSONObject localJSONObject = put(paramString, localInteger);
    return this;
  }

  public JSONObject put(String paramString, long paramLong)
    throws JSONException
  {
    Long localLong = new Long(paramLong);
    JSONObject localJSONObject = put(paramString, localLong);
    return this;
  }

  public JSONObject put(String paramString, Object paramObject)
    throws JSONException
  {
    if (paramString == null)
      throw new JSONException("Null key.");
    if (paramObject != null)
    {
      testValidity(paramObject);
      Object localObject1 = this.map.put(paramString, paramObject);
    }
    while (true)
    {
      return this;
      Object localObject2 = remove(paramString);
    }
  }

  public JSONObject put(String paramString, Collection paramCollection)
    throws JSONException
  {
    JSONArray localJSONArray = new JSONArray(paramCollection);
    JSONObject localJSONObject = put(paramString, localJSONArray);
    return this;
  }

  public JSONObject put(String paramString, Map paramMap)
    throws JSONException
  {
    JSONObject localJSONObject1 = new JSONObject(paramMap);
    JSONObject localJSONObject2 = put(paramString, localJSONObject1);
    return this;
  }

  public JSONObject put(String paramString, boolean paramBoolean)
    throws JSONException
  {
    if (paramBoolean);
    for (Boolean localBoolean = Boolean.TRUE; ; localBoolean = Boolean.FALSE)
    {
      JSONObject localJSONObject = put(paramString, localBoolean);
      return this;
    }
  }

  public JSONObject putOnce(String paramString, Object paramObject)
    throws JSONException
  {
    if ((paramString != null) && (paramObject != null))
    {
      if (opt(paramString) != null)
      {
        String str = "Duplicate key \"" + paramString + "\"";
        throw new JSONException(str);
      }
      JSONObject localJSONObject = put(paramString, paramObject);
    }
    return this;
  }

  public JSONObject putOpt(String paramString, Object paramObject)
    throws JSONException
  {
    if ((paramString != null) && (paramObject != null))
      JSONObject localJSONObject = put(paramString, paramObject);
    return this;
  }

  public Object remove(String paramString)
  {
    return this.map.remove(paramString);
  }

  public Iterator sortedKeys()
  {
    Set localSet = this.map.keySet();
    return new TreeSet(localSet).iterator();
  }

  public JSONArray toJSONArray(JSONArray paramJSONArray)
    throws JSONException
  {
    Object localObject1;
    if ((paramJSONArray == null) || (paramJSONArray.length() == 0))
    {
      localObject1 = null;
      return localObject1;
    }
    JSONArray localJSONArray1 = new JSONArray();
    int i = 0;
    while (true)
    {
      int j = paramJSONArray.length();
      if (i >= j)
      {
        localObject1 = localJSONArray1;
        break;
      }
      String str = paramJSONArray.getString(i);
      Object localObject2 = opt(str);
      JSONArray localJSONArray2 = localJSONArray1.put(localObject2);
      i += 1;
    }
  }

  public String toString()
  {
    try
    {
      Iterator localIterator = keys();
      StringBuffer localStringBuffer1 = new StringBuffer("{");
      while (true)
      {
        if (!localIterator.hasNext())
        {
          StringBuffer localStringBuffer2 = localStringBuffer1.append(125);
          str1 = localStringBuffer1.toString();
          return str1;
        }
        if (localStringBuffer1.length() > 1)
          StringBuffer localStringBuffer3 = localStringBuffer1.append(44);
        Object localObject = localIterator.next();
        String str2 = quote(localObject.toString());
        StringBuffer localStringBuffer4 = localStringBuffer1.append(str2);
        StringBuffer localStringBuffer5 = localStringBuffer1.append(58);
        String str3 = valueToString(this.map.get(localObject));
        StringBuffer localStringBuffer6 = localStringBuffer1.append(str3);
      }
    }
    catch (Exception localException)
    {
      while (true)
        String str1 = null;
    }
  }

  public String toString(int paramInt)
    throws JSONException
  {
    return toString(paramInt, 0);
  }

  String toString(int paramInt1, int paramInt2)
    throws JSONException
  {
    int i = length();
    String str1;
    if (i == 0)
      str1 = "{}";
    Iterator localIterator;
    StringBuffer localStringBuffer1;
    int j;
    label129: Object localObject2;
    label157: int k;
    while (true)
    {
      return str1;
      localIterator = sortedKeys();
      localStringBuffer1 = new StringBuffer("{");
      j = paramInt2 + paramInt1;
      if (i != 1)
        break;
      Object localObject1 = localIterator.next();
      String str2 = quote(localObject1.toString());
      StringBuffer localStringBuffer2 = localStringBuffer1.append(str2);
      StringBuffer localStringBuffer3 = localStringBuffer1.append(": ");
      String str3 = valueToString(this.map.get(localObject1), paramInt1, paramInt2);
      StringBuffer localStringBuffer4 = localStringBuffer1.append(str3);
      StringBuffer localStringBuffer5 = localStringBuffer1.append(125);
      str1 = localStringBuffer1.toString();
      continue;
      localObject2 = localIterator.next();
      if (localStringBuffer1.length() <= 1)
        break label281;
      StringBuffer localStringBuffer6 = localStringBuffer1.append(",\n");
      k = 0;
    }
    while (true)
    {
      if (k >= j)
      {
        String str4 = quote(localObject2.toString());
        StringBuffer localStringBuffer7 = localStringBuffer1.append(str4);
        StringBuffer localStringBuffer8 = localStringBuffer1.append(": ");
        String str5 = valueToString(this.map.get(localObject2), paramInt1, j);
        StringBuffer localStringBuffer9 = localStringBuffer1.append(str5);
        if (localIterator.hasNext())
          break label129;
        if (localStringBuffer1.length() <= 1)
          break;
        StringBuffer localStringBuffer10 = localStringBuffer1.append(10);
        k = 0;
        while (k < paramInt2)
        {
          StringBuffer localStringBuffer11 = localStringBuffer1.append(32);
          k += 1;
        }
        break;
        label281: StringBuffer localStringBuffer12 = localStringBuffer1.append(10);
        break label157;
      }
      StringBuffer localStringBuffer13 = localStringBuffer1.append(32);
      k += 1;
    }
  }

  public Writer write(Writer paramWriter)
    throws JSONException
  {
    int i = 0;
    while (true)
    {
      Object localObject2;
      try
      {
        Iterator localIterator = keys();
        paramWriter.write(123);
        if (localIterator.hasNext())
          continue;
        paramWriter.write(125);
        return paramWriter;
        if (i == 0)
          continue;
        paramWriter.write(44);
        Object localObject1 = localIterator.next();
        String str1 = quote(localObject1.toString());
        paramWriter.write(str1);
        paramWriter.write(58);
        localObject2 = this.map.get(localObject1);
        if (!(localObject2 instanceof JSONObject))
          continue;
        Writer localWriter1 = ((JSONObject)localObject2).write(paramWriter);
        i = 1;
        continue;
        if ((localObject2 instanceof JSONArray))
        {
          Writer localWriter2 = ((JSONArray)localObject2).write(paramWriter);
          continue;
        }
      }
      catch (IOException localIOException)
      {
        throw new JSONException(localIOException);
      }
      String str2 = valueToString(localObject2);
      paramWriter.write(str2);
    }
  }

  final class Null
  {
    protected final Object clone()
    {
      return this;
    }

    public boolean equals(Object paramObject)
    {
      if ((paramObject != null) && (paramObject != this));
      for (int i = 0; ; i = 1)
        return i;
    }

    public String toString()
    {
      return "null";
    }
  }
}

/* Location:           D:\Program Files\eclipse\apktool-r01-3\新浪微博\classes.dex.dex2jar.jar
 * Qualified Name:     sudroid.json.JSONObject
 * JD-Core Version:    0.6.0
 */